#!/usr/bin/env bash


help(){
    cat<<__EOF__
Usage: m timezone [OPTIONS]

Description: Manage the system timezone on macOS

Options:
 --help             Show this help message and exit
 --list             List available timezones
 --set TIMEZONE     Set the system timezone


Examples:
  m timezone                      # get current timezone
  m timezone --set Europe/Berlin  # set timezone
__EOF__
}

case $1 in
    --help)
        help
        ;;
    --list)
        sudo systemsetup -listtimezones
        ;;
    --set)
        [ -z "$2" ] && help && exit 1;
        sudo systemsetup -settimezone $2
        ;;
    *)
        sudo systemsetup -gettimezone
        ;;
esac
